﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using RoverStudio.Common.PositionSource;

namespace Webcam
{
    public partial class CameraDisplay : UserControl
    {
        private IVideoSourceCommon videoSource;

        public IVideoSourceCommon VideoSource
        {
            get { return videoSource; }
            set {
                if (videoSource != null)
                    videoSource.NewFrame -= new RoverStudio.Common.PositionSource.NewFrameDelegate(FrameGrabbed);
                videoSource = value;
                if (videoSource != null)
                    videoSource.NewFrame += new RoverStudio.Common.PositionSource.NewFrameDelegate(FrameGrabbed);
            }
        }

        public CameraDisplay()
        {
            InitializeComponent();
        }


        private void FrameGrabbed(Bitmap frame)
        {
            pbImage.Image = frame;
        }
    }
}
